<?php
/**
 * Created by PhpStorm.
 * User: xiong <1099446868@qq.com>
 * DateTime: 2018/12/16
 * TIME: 0:27
 * 自定义模块配置
 */

return [
    'root_namespace'         => [
        'Swoole'=> '../application/extend/Swoole/'
    ],

    // 是否开启路由延迟解析
    'url_lazy_route'         => false,
    // 是否强制使用路由
    'url_route_must'         => true,
    // 合并路由规则
    'route_rule_merge'       => true,
    // 路由是否完全匹配
    'route_complete_match'   => true,
    // 使用注解路由
    'route_annotation'       => false,

    //目录结构配置
    'category'      => [
        'zwdu' => [  //来源
                     1 => ['name' => '玄幻', 'url' => ''],
                     2 => ['name' => '修真', 'url' => ''],
                     3 => ['name' => '都市', 'url' => ''],
                     4 => ['name' => '历史', 'url' => ''],
                     5 => ['name' => '网游', 'url' => ''],
                     6 => ['name' => '科幻', 'url' => ''],
                     7 => ['name' => '言情', 'url' => ''],
                     8 => ['name' => '其他', 'url' => ''],
        ],
    ],
    //根据目录名查id
    'category_id' => [
        '玄幻小说'=>1,
        '修真小说'=>2,
        '都市小说'=>3,
        '历史小说'=>4,
        '网游小说'=>5,
        '科幻小说'=>6,
        '言情小说'=>7,
        '其他小说'=>8,
    ],
    //缓存配置

    // 小说缓存存在时间  小说详情
    'cache_time'    => 3600 * 24 * 30,
    //小说单目录
    'catalog_time'  => 3600 * 24,
    //小说全目录
    'catalogs_time' => 3600 * 6,
    //小说内容缓存时间
    'content_time'  => 3600 * 24 * 30,
    //排行榜缓存时间
    'RankingList_time' => 3600 * 24,
    //最新更新
    'LastUpdate_time' => 3600,
    //其他人都在搜
    'OtherSearch_time'=> 3600 * 24,
    //栏目
    'category_time'=> 3600 * 24 * 30,

    //站点来源信息cookie保存时间
    'source_time' => 3600,
    //推荐榜缓存时间（全部） rank
    'rank'=>3600 * 24 * 7,
    //wap站首页
    'mobile_zh_index_time'=> 3600 * 24,
    //来源
    'source'=>['','zwdu','zh'],
    'source_host'=>[
        '', //跟上吗一致，第一个元素默认为空
        'https://www.zwdu.com',
    ],
    //检索url
    'search_url' => [
        '',
        'zwdu'=>'https://www.zwdu.com/search.php?keyword=',
        'zh'=>'http://search.zongheng.com/s?keyword=',
    ],

    //xpath定义
    'xpath'         => [
        'zwdu' => [
            'content' => '//*[@id="content"]',
            'search' => [ //爬检索页
                'url'=>'https://www.zwdu.com/search.php?keyword=',
                'field'=>[ //一个页面只需要获取一次，结果只有一个
                    'lastpage'=>'/html/body/div[4]/div/a[last()]', //搜索结果可能不止一个，获取到这个就能知晓共有多少结果
                ],
                'fields'=>[//结果可能有多个
                    'link'=>[
                        'select'=>'//h3/a',
                        'node'=>false,
                    ],
//                    'bookname' =>[
//                        'select'=>'//h3/a/span',
//                        'node'=>true,  //nodeValue  不带标签的文字
//                    ],
                    'author'=>[
                        'select'=>'//*[@class="result-game-item-info"]/p[1]/span[2]',
                        'node'=>true,
                    ],
                    'lastupdate'=>[
                        'select'=>'//*[@class="result-game-item-info"]/p[4]/a',
                        'node'=>true,
                    ],
//                    'updatetime'=>[
//                        'select'=>'//*[@class="result-game-item-info"]/p[3]/span[2]',
//                        'node'=>true,
//                    ],
                    'desc'=>[
                        'select'=>'//*[@class="result-game-item-desc"]',
                        'node'=>false,  //带标签的
                    ],
                    'category'=>[
                        'select'=>'//*[@class="result-game-item-info"]/p[2]/span[2]',
                        'node'=>true
                    ],
                ],
            ],
            'searchtodetails'=>[  //爬详情页
                'field'=>[
                    'bookstatus'=>[
                        'select'=>'//*[@id="info"]/p[2]',
                        'node'=>true,
                    ],
                    'updatetime'=>[
                        'select'=>'//*[@id="info"]/p[3]',
                        'node'=>true,
                    ],
                ],
                'fields'=>[
                    'title'=>[   //章节和url
                        'select'=>'//*[@id="list"]/dl/dd/a',
                        'require'=>true,
                        'node'=>'nodeValue',
                    ],
                ]
            ],
        ],
        'zh'   => [
            'index' => [
                'url' =>'http://www.zongheng.com/',
                'select'=> [
                    'topleft'=>['/html/body/div[2]/div[3]/div[2]/div[4]/div[1]/div/a', [-1]],
                    'topright'=>['/html/body/div[2]/div[3]/div[2]/div[4]/div[2]/div/a', [1]],
                    'left' => ['/html/body/div[2]/div[3]/div[2]/div[4]/div[1]/ul', [0,-1,0,0,0]],
                    'right' => ['/html/body/div[2]/div[3]/div[2]/div[4]/div[2]/ul', [0,0,1,1,1]],
                ]
            ],
            'list'  => [  //各类榜单 Index/index
                'bestseller'    => [ //24小时畅销榜
                    'select' => '/html/body/div[2]/div[4]/div[2]/div[2]',
                    'url'    => 'http://www.zongheng.com/rank/details.html?rt=3&d=1'
                ],
                'weekclick'     => [ //周点击
                    'select' => '/html/body/div[2]/div[4]/div[2]/div[3]',
                    'url'    => 'http://www.zongheng.com/rank/details.html?rt=5&d=1'
                ],
                'weekrecommend' => [ //周推荐
                    'select' => '/html/body/div[2]/div[4]/div[2]/div[3]',
                    'url'    => 'http://www.zongheng.com/rank/details.html?rt=6&d=1'
                ],
                'month'         => [ //月票
                    'select' => '/html/body/div[2]/div[4]/div[2]/div[2]',
                    'url'    => 'http://www.zongheng.com/rank/details.html?rt=1&d=1&i=2'
                ],
                'newbook'=>[ // 新书
                    'select'=>'/html/body/div[2]/div[4]/div[2]/div[3]',
                    'url'=>'http://www.zongheng.com/rank/details.html?rt=4&d=1'
                ],
            ],
            'search'=>[
                'select'=>'',
                'url'=>'http://search.zongheng.com/s'
            ],
            'lastupdate'=>[
                'url'=>'http://www.zongheng.com/api/book/updatelist.htm',
                'select'=>'',
            ],
            'mobile'=>[ //wap端
                'index'=>[
                    'url'=>'https://m.zongheng.com/',
                    'select'=>[
                        'bianji'=>"//div[@class='home-book-item flex border-b touch-a']",
                        'boygirl'=>"//div[@class='home-card-con flex']",
                        'lanmutuijian'=>'//div[@class="home-card"]',
                    ]
                ],
                        //玄幻仙侠 等等推荐  title和url目前只能自己设
                'lanmutuijian'=>[
                    'xhxx'=>[
                        0=>'',
                        1=>'',
                        2=>'',
                        3=>'',
                    ],
                    'dsyl'=>[
                        0=>'',
                        1=>'',
                        2=>'',
                        3=>'',
                    ],
                    'khls'=>[
                        0=>'',
                        1=>'',
                        2=>'',
                        3=>'',
                    ],
                    'rmzp'=>[
                        0=>'',
                        1=>'',
                        2=>'',
                        3=>'',
                    ],
                ],
            ],

        ],
    ]
];

